﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.AuthorCenter.Users;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.AuthorCenter.Controllers
{
    [RemoteService]
    [Route("api/identity/users/tenants")]
    public class UserTenantController : AuthorCenterController
    {
        private IUserTenantAppService _appService;

        public UserTenantController(IUserTenantAppService userTenantAppService)
        {
            _appService = userTenantAppService;
        }

        [HttpGet]
        public async Task<PagedResultDto<UserTenantDto>> GetListAsync(UserTenantFilter filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpPut]
        public async Task<List<UserTenantDto>> UpdateAsync(UserTenantUpdateDto input)
        {
            return await _appService.UpdateAsync(input);
        }


        [HttpPost]
        [Route("generate-token")]
        public async Task<string> GenerateLoginToken(UserTenantSwitchDto input)
        {
            return await _appService.GenerateUserTenantLoginToken(input);
        }

        [HttpGet]
        [Route("current")]
        public async Task<UserTenantDto> GetCurrentAsync()
        {
            return await _appService.GetCurrentAsync();
        }
    }
}
